package com.redbox.RedboxManagment.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.redbox.RedboxManagment.dao.IUser;
import com.redbox.RedboxManagment.ejb.User;

@Service
public class UserServiceImp implements IUserService {

	@Autowired(required=true)
	private IUser userDao;
	
	@Override
	@Transactional
	public User retrieveUsingId(int pId) {
		User user = userDao.findById(pId);
		return user;
	}

	@Override
	@Transactional
	public User retrieveUsingName(String name) {
		User user = userDao.findByName(name);
		return user;
	}

	@Override
	@Transactional
	public User create(User pUser) {
		User user = userDao.persistOnMerge(pUser);
		return user;
	}

	@Override
	public List<User> findAll() {
		List<User> userList = userDao.findAll();
		return userList;
	}
	
	

}
